<?php
/**
 * Created by PhpStorm.
 * User: 64423
 * Date: 2018/10/10
 * Time: 11:32
 */

namespace app\shop\model;


use think\Model;

class GoodsSpecModel extends Model
{
    protected $table = 'dp_goods_spec';

    public static function getByGoodsId($goods_id)
    {
        return self::where('goods_id', $goods_id)->select();
    }

    public static function getByKey($key)
    {
        return self::where('key', $key)->find();
    }

    public static function saveByGoodsId($goods_id, $arr)
    {
        self::delByGoodsId($goods_id);
        $res = false;
        foreach ($arr as $item){
            $res = self::create($item);
        }
        return $res;
    }

    public static function delByGoodsId($goods_id)
    {
        return self::where('goods_id',$goods_id)->delete();
    }
}